﻿//作者：MrLee
//时间：2011-9-22
//名称：人员查询
//作者：MrLee
//时间：2011-8-23
//名称：日志管理
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');
FantastPlatform.UI.PersonSearchGrid = function (config) {
    Ext.apply(this, config);
    var fileStore = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '../Service/PersonSearchService.aspx?Action=Search'

        }),
        reader: new Ext.data.JsonReader({
            root: 'topics',
            totalProperty: 'totalCount',
            id: 'Id',
            fields: ['Id', 'Name', 'Phone', 'QQ', 'Sex', 'IdCard', 'BaseInfo','CreateDateStr','ModifyDate']
        }),
        remoteStore: true
    });
    this.store = fileStore;

    var paperBar = new FantastPlatform.Common.PapeToolBar({
        store: fileStore,
        noSort: true,
        defaultNum: 21
    });
    this.paperBar = paperBar;
    this.bbar = paperBar;
    this.pageNumber = paperBar.pageSize;

    var nm = new Ext.grid.RowNumberer();
    var sm = new Ext.grid.CheckboxSelectionModel();

    this.columns = [nm, sm, {
        header: 'Id',
        dataIndex: 'Id',
        hidden: true
    }, {
        header: '姓名',
        dataIndex: 'Name',
        sortable: true
    }, {
        header: '电话',
        dataIndex: 'Phone',
        sortable: true
    }, {
        header: 'QQ',
        dataIndex: 'QQ',
        sortable: true
    }, {
        header: '性别',
        dataIndex: 'Sex',
        sortable: true
    }, {
        header: '身份证',
        dataIndex: 'IdCard',
        sortable: true
    }, {
        header: '详细信息',
        dataIndex: 'BaseInfo',
        sortable: true,
        width: 300
    }
    , {
        header: '录入时间',
        dataIndex: 'CreateDateStr',
        sortable: true       
    }
    , {
        header: '迁走时间',
        dataIndex: 'ModifyDate',
        sortable: true
      
    }];

    FantastPlatform.UI.PersonSearchGrid.superclass.constructor.call(this, {
        loadMask: { msg: '正在加载数据...' },
        sm: sm
    });
};
Ext.extend(FantastPlatform.UI.PersonSearchGrid, Ext.grid.GridPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.PersonSearchGrid.superclass.onRender.call(this, ct, position);
    },
    //查看
    onEditPersonCheckGridClick: function () {
        var node = checkGridSelected(this);
        if (node) {
            if (node.length > 1) {
                showErrorMessage("操作失败", "只能选择一条数据进行查看", "");
            } else {
                var fId = node[0].get('Id');
                var id = GUID();
                currtWind = openWind('../InfoCollection/PersonCheckForm.aspx?Id=' + fId, id, '查看', 480, 150, null);
            }
        }
    },
    //查询
    onSearchClick: function () {
        var id = GUID();
        currtWind = openWind('../InfoCollection/PersonSearchFrom.aspx', id, '查询信息', 350, 180, 'new_tab');
    },
    //刷新
    onUpdataPersonSearchGridClick: function () {
        this.store.removeAll();
        this.store.proxy.conn = { method: 'post', url: this.url };
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    },
    //查看详细信息
    onEditPersonDetailsCheckGridClick: function () {
        var node = checkGridSelected(this);
        if (node) {
            if (node.length > 1) {
                showErrorMessage("操作失败", "只能选择一条数据进行查看", "");
            } else {
                var fId = node[0].get('Id');
                var id = GUID();
                currtWind = openWind('../InfoCollection/PersonDetailsForm.aspx?Id=' + fId, id, '查看', 600, 445, null);
            }
        }
    },
     //历史记录
    onUpdataPersonHistoryGridClick: function () {
        this.store.removeAll();
        this.store.proxy.conn = { method: 'post', url:'../Service/PersonSearchService.aspx?Action=SearchHistory'  };
        this.store.load({ params: { start: 0, limit: this.paperBar.getPageNumber(), dir: '', sort: ''} });
    }
});